<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="Generator" content="ALORK 20150428.01" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Keywords" content="<?php echo $this->_var['keywords']; ?>" />
<meta name="Description" content="<?php echo $this->_var['description']; ?>" />
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

<title><?php echo $this->_var['page_title']; ?></title>

<link rel="shortcut icon" href="favicon.ico" />
<link rel="icon" href="animated_favicon.gif" type="image/gif" />
<link rel="stylesheet" href="./public/my_style.css" />
<link rel="stylesheet" href="./public/style.css" />
<?php echo $this->smarty_insert_scripts(array('files'=>'./../js/region.js,./../js/user.js,./../js/common.js,./../js/jquery.js,./../js/jquery.json-1.3.js,./../js/mobile-common.js,./../js/upload.js')); ?>

</head>
<body >

<?php echo $this->fetch('library/user_head.lbi'); ?>

<?php if ($this->_var['action'] == sale_service): ?>
<div id="sale_service">
<form action="user.php" id="sale_form"  method="post" name="sale_form">
<?php $_from = $this->_var['goods_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'goods');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['goods']):
?>
	<div class="goods_box">
		<div class="goods_id">
			 <input type="checkbox" class="none" name="rec_id[]" value="<?php echo $this->_var['goods']['rec_id']; ?>" />
		</div>
		<div class="img"><img src="../<?php echo $this->_var['goods']['goods_thumb']; ?>" alt=""  width="100%"/></div>
		<div class="note">
			<div class="name"><?php echo $this->_var['goods']['goods_name']; ?><?php if ($this->_var['goods']['goods_attr']): ?>(<?php echo $this->_var['goods']['goods_attr']; ?>) <?php endif; ?></div>
			<div class="num">数量：<?php echo $this->_var['goods']['goods_number']; ?>  </div>

			<div class="num_box"><span class="reduce">-</span>  <input type="text" name="goods_num[<?php echo $this->_var['goods']['rec_id']; ?>]" readonly="readonly"  class="goods_num" value="1"/>  <span class="add">+</span>  <input type="hidden" class="max_num" value="<?php echo $this->_var['goods']['goods_number']; ?>"/> </div> 
			
		</div>
	</div>
<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
<input type="hidden" name="order_id"  value="<?php echo $this->_var['order_id']; ?>"/>
<input type="hidden" name="act"  value="sale_service_form"/>
<div class="next" onclick="sale_submit();">下一步</div>
</form>
</div>


<script>
$(".none").attr("checked", false);
$(".goods_id").toggle(
  function(){
  $(this).addClass("selected");
  $(this).find(".none").attr("checked", true);
  },
  function(){
  $(this).removeClass("selected");
  $(this).find(".none").attr("checked", false);
  }
);
$(".reduce").click(function(){
	var num = parseInt($(this).siblings('.goods_num').val());
	var new_num = 1;
	if(num-1>0){
		new_num =num-1;
	}
	$(this).siblings('.goods_num').val(new_num);
});
$(".add").click(function(){
	var num = parseInt($(this).siblings('.goods_num').val());
	var max_num = parseInt($(this).siblings('.max_num').val());
	var new_num = parseInt($(this).siblings('.max_num').val());

	if(num+1<max_num){
		new_num =num+1;
	}
	$(this).siblings('.goods_num').val(new_num);
});
function sale_submit(){
 if($(".selected").length<=0){
  point("请选择售后商品",1);
  return false
 }
 $("#sale_form").submit();
}
</script>
<?php endif; ?>

<?php if ($this->_var['action'] == sale_service_form): ?>
<div id="sale_service_form">
	<form action="user.php" onsubmit="return submit_service_form();" method="post" name="service_form" id="submit_service_form">
	<div class="order_sn">订单编号：<?php echo $this->_var['order_info']['order_sn']; ?> (<?php echo $this->_var['goods_number']; ?>) <span class="arrow"></span></div>
	<div class="connent">
		<div class="goods_list">
			<?php $_from = $this->_var['goods_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'goods');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['goods']):
?>
			<div class="goods_son">
				<div class="img"><img src="../<?php echo $this->_var['goods']['goods_thumb']; ?>" alt="" width="100%" /></div>
				<div class="note">
					<div class="goods_name"><?php echo $this->_var['goods']['goods_name']; ?> <?php if ($this->_var['goods']['goods_attr']): ?> (<?php echo $this->_var['goods']['goods_attr']; ?>) <?php endif; ?> </div>
					<div class="goods_num">数量：<?php echo $this->_var['goods']['goods_number']; ?></div>
				</div>
			</div>
			<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
		</div>

		<div class="cell">退款类型<span class="red">*</span><span class="cell_right" id="cell_right">售后规则说明>></span></div>
		<div class="service_type">
			<span class="type_left">选择退款原因</span>
			
			<span class="arrow"></span>
			<span class="type_right"></span>
			<select name="service_type"  id="service_type" class="none">
                       <option value="-1">选择退款原因</option>
                      <?php $_from = $this->_var['lang']['sale_question']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'question');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['question']):
?>
                                          <option value="<?php echo $this->_var['key']; ?>"><?php echo $this->_var['question']; ?></option>
                      <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
            </select>

		</div>
		<div class="cell">处理方式<span class="red">*</span></div>
		<div class="handle_type">
			<div class="handle_type-1">退款（无需退货）<span class="select"><input type="radio" name="handle_type" value="1" checked></span></div>
			<div class="handle_type-2">退货<span class="select"><input type="radio" name="handle_type" value="2" checked></span></div>
		</div>
		<div class="cell">退款金额 <span class="font12">最多<span class="red"><?php echo $this->_var['price_count']; ?> 元</span></span></div>
		<div class="price"> <input type="text" name="refund_money" placeholder="请输入退款金额" class="refund_money" value="<?php echo $this->_var['price_count']; ?>"  onkeyup="price_point(this);" onblur="price_null(this);" /></div>
		<div class="cell">问题描述</div>
		<div class="question_note">
			<input type="text"  placeholder="请输入问题说明" name="question_note" class="note"/>
			<div class="pic_box">
				<div id="pic" class="none"></div>

				<div class="upload">
          		</div>
          		<input type="file"  name="file" id="file"   accept="image/*"  onchange="javascript:ajaxFileUpload();" />
				<span class="pic_right"> 上传凭证最多3张</span>
			</div>
		</div>
	
		<div class="row">联系人姓名：<input type="text" name="consignee" class="input_consignee" value="<?php echo $this->_var['order_info']['consignee']; ?>"/></div>
		<div class="row">手机号码：<input type="text" name="mobile"    class="input_mobile" value="<?php echo $this->_var['order_info']['mobile']; ?>"/></div>
		<div class="row">支付宝账号：<input type="text" name="payment_num" class="input_payment" placeholder="请输入退款账号" value=""/></div>

	    <input type="hidden"  name ='act' value="sale_service_handle"/>
        <input type="hidden"  name ='order_sn' value="<?php echo $this->_var['order_info']['order_sn']; ?>"/>
        <input type="hidden"  name="goods_num" value="<?php echo $this->_var['goods_num']; ?>"/>
		<div class="submit" onclick="$('#submit_service_form').submit();" >提交申请</div>
	</div>
	</form>







<div id="big_box">
	<div class="service_type_select">
		<div class="top">选择退款原因 <span class="arrow"></span></div>
		<div class="cell">
			<span class="select"></span>
			商品实物与订单不符<br />
			<span class="font12">上传全部商品的照片一张，错发商品的照片一张</span>

		</div>
		<div class="cell">
			<span class="select"></span>
			物流损坏<br />
			<span class="font12">上传包裹填充物和纸箱的照片一张，损坏物品的照片一张</span>
		</div>
		<div class="cell">
			<span class="select"></span>
			个人原因<br />
			<span class="font12">需客户支付退回邮费</span>
		</div>
		<div class="cell">
			<span class="select"></span>
			数量不符<br />
			<span class="font12">上传全部商品的照片一张</span>
		</div>		
		<div class="cell">
			<span class="select"></span>
			质量问题<br />
			<span class="font12">上传出现质量问题的照片一张</span>
		</div>
	</div>
</div>
</div>


<div id="big_box-2">
  <div class="rule">
    <div class="top">售后规则说明<span class="rele_delete" onclick="$('#big_box-2').hide();"></span></div>
    <div class="cell">
      商品实物与订单不符
      <span class="cell_right">退货</span>
    </div>
    <div class="cell">
      物流破损
      <span class="cell_right">退款</span>
    </div>
    <div class="cell">
      自己不喜欢
      <span class="cell_right">退货</span>
    </div>
    <div class="cell">
      数量不符
      <span class="cell_right">退货</span>
    </div>    
    <div class="cell">
      质量问题
      <span class="cell_right">退款</span>
    </div>
        <div class="sale_note_text">
      <p>如您不清楚应该如何选择，请咨询在线客服<br /></p>
      <span class="font16">注意事项：</span>
      <p>1、售后条款15天适用。于签收日次日零时起算。如15日内没有申请售后，则不能受理。<br /></p>
      <p>2、退货邮费由客户垫付。退货完成后由鸡蛋美术商城退还邮费。<br /></p>
      <p>3、退货需要客户于退货后填写相关物流信息。（客服审核售后订单后进入“个人中心->售后订单”内填写）。若不填写，则视为放弃售后申请。<br />
     </p>
      <p>4、关于商品实物与订单不符：鸡蛋美术商城保证所出售的商品均为正品。但因为藏家会在没有任何提前通知的情况下更换包装，所以我们无法确保您收到的商品与商城图片完全一致。<br />      
      </p>
      <p> 5、关于物流损坏：极大美术商城保证所出售的商品均完好无损并经过妥善包装。请收货时留意外包装是否破损，尽量当面开箱验货。.</p>
      <p>6、活动期间的特价商品，如果发生退款申请，以该活动的售后说明为准。</p>
    </div>
  </div>
</div>




<script>
	$(".service_type").click(function(){
		$('#big_box').show();

	});
  $("#cell_right").click(function(){
    var height = $('#sale_service_form').height();
    $('#big_box-2').height(height+49);
    $('#big_box-2').show();
  });



	$(".order_sn").toggle(
  function(){
  $(".goods_list").height('auto');},
  function(){
  $(".goods_list").height('0');}
);




	$(".upload").click(function(){
		 var pic_length = $(".pic").length;
            if(pic_length>=3){
            
              return false
            }
            else{
            	$('#file').click();
            }
		
	});


	$(".handle_type").find('.select').click(function(){
		$(".handle_type").find('.select').removeClass('selected');
		$(this).addClass('selected');
	});
	$(".service_type_select").find('.cell').click(function(){
		var index_ = $(this).index();
		$(".service_type_select").find('.select').removeClass('selected');
		$(this).find('.select').addClass('selected');
		var text =$('#service_type').find('option').eq(index_).text();
		$('.type_right').text(text);
		$('#service_type').find('option').attr("selected", '');
		$('#service_type').find('option').eq(index_).attr("selected", 'selected');
		$('#big_box').hide();
	});

      function ajaxFileUpload() {
          //判断是否已有3张图片

            $.ajaxFileUpload
            (
                {
                    url: 'upload_sale.php', //用于文件上传的服务器端请求地址
                    secureuri: false, //是否需要安全协议，一般设置为false
                    fileElementId: 'file', //文件上传域的ID
                    dataType: 'json', //返回值类型 一般设置为json
                    success: function (data, status)  //服务器成功响应处理函数
                    {
                      var pic ="<div class='pic' ><div class='delete' onclick='pic_delete(this);'></div><img src='../"+data.pic+"'/><input type='hidden' name='pic[]' value='../"+data.pic+"'></div>";
                      $('#pic').after(pic);
                    },
                    error: function (data, status, e)//服务器响应失败处理函数
                    {
                        alert('上传失败');
                    }
                }
            )
            return false;
        }
  //表单提交判断
    function submit_service_form(){
      var sale_question=document.forms['service_form'].elements['service_type'].value;//遇到的问题
      var question_note=document.forms['service_form'].elements['question_note'].value;//问题描述
      var handle_type=document.forms['service_form'].elements['handle_type'].value;//处理方式
      var consignee=document.forms['service_form'].elements['consignee'].value;//联系人
      var mobile=document.forms['service_form'].elements['mobile'].value;//电话
      var payment_num=document.forms['service_form'].elements['payment_num'].value;//支付宝账号
      var refund_money=document.forms['service_form'].elements['refund_money'].value;//支付宝账号

      if(sale_question<0){
        prompt('请选择遇到的问题',"$('#prompt').remove()");
        return false
      }
      if(handle_type<0){
      	prompt('请选择处理方式',"$('#prompt').remove()");
        return false
      }
      if(consignee==""||mobile==""){
        prompt('请填写联系方式',"$('#prompt').remove()");
        return false
      }
      if(payment_num==""){
        prompt('请填写退款支付宝账号',"$('#prompt').remove()");
        return false
      }
      if(refund_money==""){
        prompt('请输入退款金额',"$('#prompt').remove()");
        return false
      }
      return true
    }
    function pic_delete(obj){
    	var index_ = $(obj).index();
 		prompt('是否删除图片',"$('.pic').eq("+index_+").remove();$('#prompt').remove();");
    }
</script>

<?php endif; ?>

<?php if ($this->_var['action'] == done): ?>
<div id="sale_done">
	<img src="./images/sale/done.png" alt="" width="100%;"/>
	<a href="user.php?act=sale_list" class="done">查看售后</a>
</div>
<?php endif; ?>
<?php if ($this->_var['action'] == error): ?>
<div id="sale_done">
  请勿重复提交
  <a href="user.php?act=sale_list" class="done">查看售后</a>
</div>
<?php endif; ?>

<?php if ($this->_var['action'] == sale_list): ?>
<div id="sale_list">
<?php if ($this->_var['sale_list']): ?>
<?php $_from = $this->_var['sale_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'sale');if (count($_from)):
    foreach ($_from AS $this->_var['sale']):
?>
<a href="user.php?act=sale_detail&service_id=<?php echo $this->_var['sale']['service_id']; ?>">
	<div class="sale_son">
		<div class="order_sn">订单号：<?php echo $this->_var['sale']['order_sn']; ?></div>
		<div class="connent">
			<div class="img"><img src="../<?php echo $this->_var['sale']['goods_thumb']; ?>" alt="" /></div>
			<div class="sale_question">问题类型：<?php echo $this->_var['lang']['sale_question'][$this->_var['sale']['service_type']]; ?></div>
			<div class="time"><?php echo $this->_var['sale']['add_time']; ?></div>
			<div class="num">数量：<?php echo $this->_var['sale']['goods_number']; ?></div>
			<div class="start">状态：<span class="red"><?php echo $this->_var['lang']['hst'][$this->_var['sale']['handle_state']]; ?></span></div>
		</div>
	</div>
</a>
<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
<?php else: ?>
<div class="no_sale">
  
  <img src="./images/sale/no_sale.png" alt="" />
  <a href="index.php" >去逛逛</a>
</div>
<?php endif; ?>
</div>
<?php endif; ?>


<?php if ($this->_var['action'] == sale_detail): ?>
<div id="sale_detail">
	<div class="sale_son">
		<div class="order_sn">订单号：<?php echo $this->_var['sale_info']['order_sn']; ?></div>
		<?php $_from = $this->_var['sale_info']['goods']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'goods');if (count($_from)):
    foreach ($_from AS $this->_var['goods']):
?>
		<div class="connent">
			<div class="img"><img src="../<?php echo $this->_var['goods']['goods_thumb']; ?>" alt="" /></div>
			<div class="goods_name"><?php echo $this->_var['goods']['goods_name']; ?> <?php if ($this->_var['goods']['goods_attr']): ?>(<?php echo $this->_var['goods']['goods_attr']; ?>)<?php endif; ?> </div>
			<div class="price">价格：<span class="red">￥<?php echo $this->_var['goods']['goods_price']; ?></span></div>
			<div class="num">数量：<?php echo $this->_var['goods']['goods_number']; ?></div>
		</div>
		<?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
	</div>

<?php if ($this->_var['sale_info']['handle_state'] == 5): ?>
    <div class="order_return">
    <form action="user.php" onsubmit="order_return(); return false;">
      
       <div class="cell">快递单号: 		<input type="text" id="express_sn"  placeholder="请输入快递单号" /></div>
       <div class="cell">物流公司: 		    <span class="arrow"></span>   <span class="express_id">选择物流公司</span>              
       				<select name="express_id" id="express_id" >
                      <option value = "0">选择物流公司</option>
                      <?php $_from = $this->_var['express_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'express_list');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['express_list']):
?>
                      <option value="<?php echo $this->_var['key']; ?>" <?php if ($this->_var['return_info']['express_id'] == $this->_var['key']): ?> selected="selected"<?php endif; ?> ><?php echo $this->_var['express_list']; ?></option>
                      <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                    </select>
       </div>
       <div class="cell">退货地址: 		<input type="text" id="address"  name="address"  placeholder="请输退货地址" value="<?php echo $this->_var['consignee']['address']; ?>"/></div>
       <div class="cell">退货人: 		<input type="text" id="consignee"  name="consignee"  placeholder="请输退货人" value="<?php echo $this->_var['consignee']['consignee']; ?>"/></div>
       <div class="cell">退货人电话: 	<input type="text" id="mobile"  name="mobile"  placeholder="请输退货人电话" value="<?php echo $this->_var['consignee']['mobile']; ?>"/></div>
       <input type="hidden" id="return_id" value="<?php echo $this->_var['return_id']; ?>"/>
       <input type="hidden" id="service_id" value="<?php echo $this->_var['sale_info']['service_id']; ?>"/>
       <div class="submit" onclick="order_return();">提交退货单</div>
     </form>
    </div>
  <script type="text/javascript">
    function order_return(){
        var express_id = $('#express_id').val();
        var express_sn = $('#express_sn').val();
        var return_id  = $('#return_id').val();
        var service_id = $('#service_id').val();
        var address    = $('#address').val();
        var consignee  = $('#consignee').val();
        var mobile     = $('#mobile').val();
        if(express_id <=0){        
        point('请选择快递公司',1);
        return false
        }
        if(express_sn ==""){        
        point('请填写快递单号',1);
        return false
        }
        if(service_id ==""){        
        point('参数错误',1);
        return false
        }
        if(consignee ==""){        
        point('退货人名称',1);
        return false
        }
        if(address ==""){        
        point('请填写退货地址',1);
        return false
        }
        if(mobile ==""){        
        point('退货人联系电话',1);
        return false
        }


      var url="user.php?act=order_return&r="+Math.random();
      var return_info =
      {
        'express_id': $('#express_id').val(),           //快递ID
        'express_sn': $('#express_sn').val(),       //快递单号
        'return_id' : $('#return_id').val(),       //退货单ID
        'service_id': $('#service_id').val(),       //售后单ID
        'address'   : $('#address').val(),       //退货地址
        'mobile'    : $('#mobile').val(),       //退货地址
        'consignee' : $('#consignee').val(),       //退货地址
      };


        htmlobj=$.post(url, {'return_info' : return_info}, function(data){
          order_return_r(data);
        },'JSON');





    }
    function order_return_r(data){
      if(data.error==2){
        point(data.content,1);
      }
      if(data.error==1){
      	prompt('提交成功','window.location.reload();');
      }
    }
    $('#express_id').change(function(){
    	var text =$('#express_id').find('option:selected').text();
    	$('.express_id').text(text);
    });


  </script>


    </form>
<?php endif; ?>
	<div class="message_box">
		<div class="title">留言/凭证记录</div>
		<?php $_from = $this->_var['sale_info']['handle_record']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'item');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['item']):
?>
			<div class="message">
				<div class="top">
					<?php if ($this->_var['item']['handle_id'] == 1): ?>
					<?php echo $this->_var['item']['handle_user']; ?>
					<?php else: ?>
					鸡蛋美术商城
					<?php endif; ?>
					<span class="right"><?php echo $this->_var['item']['add_time']; ?></span>
				</div>
				<div class="content">
					<?php echo $this->_var['item']['content']; ?>
				</div>
			</div>
        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
	</div>

</div>
<?php endif; ?>




</body>
</html>